package main

import "fmt"

// 结论：return 不是原子操作。
func main() {
	fmt.Println("t2:", t2())

	fmt.Println("t3:", t3())

	fmt.Println("t4:", t4())

}

func t2() (a int) {
	defer func() {
		a++
	}()
	return 1
}

func t3() (b int) {
	a := 1
	defer func() {
		a++
	}()
	return 1
}

func t4() (a int) {
	defer func(a int) {
		a++ //重置 a = 1
	}(a)
	return 1
}
